manage access rights on different types

I try to set access rights on different types for SCLE_SFE group.

I would set them from a root folder in which there are some other folders, projects and modules. Each type of item must have their own rights.

For the moment I run the script from a module.

Why the set function does not modify ma rights ? Do I forget anything ?

 

bool showAcl(string user, AccessRec acl, string type) {
string thisuser = (username acl)
 
if (thisuser != user) return false
print "User: " user " has "
bool something = false
if (read acl) {
something = true
print "read "
}
if (modify acl) {
something = true
print "modify "
}
if (delete acl) {
something = true
print "delete "
}
if (control acl) {
something = true
print "control "
}
if (!something) print "no "
print "powers on " type "\n"
return true

 

 Folder f

string ar
bool trouve = false
for acl in current Folder do{
ar = set (current Folder, read,"SCLE_SFE")
if (showAcl(user, acl, "current folder")) {
found = true
break
}
print "SCLE_SFE has" ar "access\n"
}

 


Estebell - Tue Sep 24 05:01:52 EDT 2013

Re: manage access rights on different types
llandale - Tue Sep 24 13:36:35 EDT 2013

[1] You failed to declare "acl"; which you are using as a 'string'.  Ditto for "Found".  TURN OFF AUTODECLARE.  I have noticed that the "for x in y do" loop in DXL allows you to not declare variable "x" even with autodeclare off.  Curious.

[2] You are setting ..err.. trying to set folder accesses inside a loop that is ..err.. trying to loop through that folder's accesses.  No, set the access first and THEN loop through checking it out.

[3]  Looks like function showAcl() recursively calls itself with no means of escape.  Maybe you are misssing "}" above the "Folder f" command.

[4] The return of "set" is an error message; your variable "ar".

[5] Does your module "inherit" rights from the Folder?

-Louie

Re: manage access rights on different types
Estebell - Wed Sep 25 03:55:18 EDT 2013

Thank's for your help !

I have still a problem with my "for ar in i do" loop : I only enter once in this loop... and the error message is on "string user = username ar" : ar semms to be null.

 

Folder f
AccessRec acl
Item i
string user = "SCLE_SFE"
string mess
string setting
bool found = false
AccessRec ar
 
for i in current Folder do{
  print (name i) "\n"
  inherited (i)
  setting = set (current Folder, read, "SCLE_SFE")
  for ar in i do {
    print "hello"
    ar = get (i, "Everyone", mess)
    string user = username ar
    print user
    if (showAcl(user, acl, "current folder")) {
      print username (acl)
      break
    }
   }
}

Re: manage access rights on different types
llandale - Wed Sep 25 12:33:36 EDT 2013

Estebell - Wed Sep 25 03:55:18 EDT 2013

Thank's for your help !

I have still a problem with my "for ar in i do" loop : I only enter once in this loop... and the error message is on "string user = username ar" : ar semms to be null.

 

Folder f
AccessRec acl
Item i
string user = "SCLE_SFE"
string mess
string setting
bool found = false
AccessRec ar
 
for i in current Folder do{
  print (name i) "\n"
  inherited (i)
  setting = set (current Folder, read, "SCLE_SFE")
  for ar in i do {
    print "hello"
    ar = get (i, "Everyone", mess)
    string user = username ar
    print user
    if (showAcl(user, acl, "current folder")) {
      print username (acl)
      break
    }
   }
}

Delete this line

  • ar = get (i, "Everyone", mess)

I see you have done this:

  • for ar in i do {
  •    ar = get (i, "Everyone", mess)
  •    whatever
  • }

Modifying the loop control variable inside the loop is as bad as drinking red wine with fish. Sheeeesh.   In this case I think the "Everone else" group is always the last AR in the list; thus when you go back to the top of the loop, you are done.  What you have done is very much like this:

  • for (i = 0; i<5; i++)
  • {  i = 4
  •    do something with i
  • }

-Louie

It seems to me that if you need to modify the loop control variable inside the loop, then you have not conceptualized your loop well, and the next person to read your code will be thankful if you do.